#include <iostream>
#define N 100

using namespace std;

void read_matrix(int matrix[N][N], int row, int column){
int i, j;
for (i=0;i<row;i++)
    for(j=0;j<column;j++){
        cout<<"m["<<i<<"]["<<j<<"]= ";
        cin>>matrix[i][j];}
}

int div_by_k(int matrix[N][N], int row, int column, int k){
int numbers=0;
int i, j;
for (i=0;i<row;i++)
    for(j=0;j<column;j++)
        if(matrix[i][j]%k==0)
        ++numbers;
return numbers;
}


int main(){
int row;
int column;
int k;
int result;
int matrix[N][N];

cout<<"Type the number of rows: " ;
cin>>row;

cout<<"Type the number of columns: " ;
cin>>column;

read_matrix(matrix, row, column);

cout<<"A number to test divisibility:";
cin>>k;

result=div_by_k(matrix, row, column, k);
cout<<"The number of elements divisible with "<<k<<" is: ";
cout<<result<<"\n";

return 0;
}
